package com.ch09c;

public class Hotel {
	// Static Members
	private static int noOfHotels = 12;
	private static Hotel[] hotelPool = createHotelPool(); // (3)

	private static Hotel[] createHotelPool() { // (4)
		try {
			if (noOfHotels > 10)
				throw new TooManyHotelsException();
		} catch (TooManyHotelsException e) {
			noOfHotels = 10;
			System.out.println("No. of hotels adjusted to " + noOfHotels);
		}
		return new Hotel[noOfHotels];
	}

	// Instance Members
	private int noOfRooms = 215;
	private int occupancyPerRoom = 5;
	private int maxNoOfGuests = initMaxGuests();

	private int initMaxGuests() { // (6)
		if (occupancyPerRoom > 4)
			throw new RoomOccupancyTooHighException();
		return noOfRooms * occupancyPerRoom;
	}
}
